#include "CBaseObject.h"
#include "../core/CDirect3D.h"
#include "../core/CCamera.h"
#include "CObjectManager.h"

CBaseObject::CBaseObject(void)
{
}

CBaseObject::~CBaseObject(void)
{
}

void CBaseObject::Initialize()
{
	m_fDepth = -1.0f;
	memset(&m_vfPosition, 0, sizeof(POINT));
	memset(&m_vfCollisionBox, 0, sizeof(RECT));
}

void CBaseObject::Initialize(int posX, int posY, float depth, int collisionWidth, int collisionHeight)
{
	m_vfPosition.x = posX;
	m_vfPosition.y = posY;
	m_fDepth = depth;
	
	m_vfCollisionBox.left	= -(collisionWidth / 2);
	m_vfCollisionBox.top	= -(collisionHeight / 2);
	m_vfCollisionBox.right	= (collisionWidth / 2);
	m_vfCollisionBox.bottom	= (collisionHeight / 2);

	m_pObjMan = CObjectManager::GetInstance();
}

void CBaseObject::Input(CRetroInput* pInput)
{
}

void CBaseObject::Update(float fDeltaTime)
{
}

void CBaseObject::Render(CDirect3D* pRender, CCamera* pCamera)
{
	const POINT& camPos = pCamera->GetCameraOffset();
	RECT drawBox;
	drawBox.left	=	m_vfCollisionBox.left	+ m_vfPosition.x - camPos.x;
	drawBox.top		=	m_vfCollisionBox.top	+ m_vfPosition.y - camPos.y;
	drawBox.right	=	m_vfCollisionBox.right	+ m_vfPosition.x - camPos.x;
	drawBox.bottom	=	m_vfCollisionBox.bottom	+ m_vfPosition.y - camPos.y;
	pRender->DrawRect(drawBox, 128, 128, 128);
}

void CBaseObject::Destroy()
{
}

bool CBaseObject::CheckCollision(IBaseObject* pObject)
{

	return false;
}

void CBaseObject::SetPosition(LONG posX, LONG posY)
{
	m_vfPosition.x = posX;
	m_vfPosition.y = posY;
}

void CBaseObject::SetPosition(POINT pos)
{
	SetPosition(pos.x, pos.y);
}